package com.jdzy.student.controller;

import com.jdzy.model.common.vos.ResultA;
import com.jdzy.model.student.dtos.StudentTagDTO;
import com.jdzy.model.student.dtos.TagDTO;
import com.jdzy.model.student.pojos.Tag;
import com.jdzy.student.service.TagService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin(allowCredentials ="true",origins = "*",allowedHeaders = "*")
@RequestMapping("/api/tag")
@RestController
@Api(value = "Tag的controller类")
public class TagController {
    @Autowired
    private TagService tagService;
    @GetMapping("/student/{stuId}")
    public ResultA<StudentTagDTO> getStudentTagsByStuId(@PathVariable("stuId") String stuId) {
        return tagService.getStudentTagsByStuId(stuId);
    }

    @PostMapping("/saveOrUpdate")
    public ResultA<Tag> saveOrUpdateTag(@RequestBody TagDTO tagDTO) {
        return tagService.saveOrUpdateTag(tagDTO);
    }

    @DeleteMapping("/delete/{tagId}/{stuId}")
    public ResultA<Void> deleteTag(@PathVariable("tagId") Long tagId, @PathVariable("stuId") String stuId) {
        return tagService.deleteTag(tagId, stuId);
    }

}
